package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.SettingMapper;
import com.tanhua.model.domain.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author: Liking
 * @description
 * @date: 2023/7/25 15:48
 */
@DubboService
public class SettingApiImpl implements SettingApi{

    @Autowired
    private SettingMapper settingMapper;

    /**
     * 根据用户id查询用户配置
     * @param userId
     * @return
     */
//根据用户id查询
    public Settings findByUserId(Long userId) {
        QueryWrapper<Settings> qw = new QueryWrapper<>();
        qw.eq("user_id",userId);
        return settingMapper.selectOne(qw);
    }

    @Override
    public void save(Settings settings) {
        settingMapper.insert(settings);
    }

    @Override
    public void update(Settings settings) {
        settingMapper.updateById(settings);
    }
}
